package AbstractTransactions

import (
	"SPC/Database"
	"SPC/Model"
	"SPC/ModelImplementation"
)

type AddEmployeeTransaction struct {
	itsEmpid   int
	itsName    string
	itsAddress string
	//声明两个基类方法，让子类来实现
	GetClassification func() Model.PaymentClassification
	GetSchedule       func() Model.PaymentSchedule
}

func NewAddEmployeeTransaction(empid int, name string, address string) *AddEmployeeTransaction {
	return &AddEmployeeTransaction{
		itsEmpid:   empid,
		itsName:    name,
		itsAddress: address,
	}
}

func (a *AddEmployeeTransaction) Execute() {
	pc := a.GetClassification()
	ps := a.GetSchedule()
	pm := ModelImplementation.HoldMethod{}
	e := Model.NewEmployee(a.itsEmpid, a.itsName, a.itsAddress)
	e.SetClassification(pc)
	e.SetSchedule(ps)
	e.SetMethod(&pm)                                          //有问题
	Database.GetPayrollDatabase().AddEmployee(a.itsEmpid, *e) //有问题
}
